package com.uphone.kingmall.activity.personal.set;

import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.china.zhuoyue.R;
import com.lzy.okgo.model.Response;
import com.uphone.kingmall.base.BaseActivity;
import com.uphone.kingmall.base.UserCertifyBean;
import com.uphone.kingmall.listener.onNormalRequestListener;
import com.uphone.kingmall.utils.CommonUtil;
import com.uphone.kingmall.utils.GsonUtils;
import com.uphone.kingmall.utils.MyUrl;
import com.uphone.kingmall.utils.OkGoUtils;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * <pre>
 *     author : 王雨
 *     e-mail : sunzengyan@outlook.com
 *     time   : 2018/07/31
 *     desc   :修改支付密码
 *     version: 1.0
 * </pre>
 */
public class PayPwdManagerActivity extends BaseActivity {

    @BindView(R.id.ll)
    LinearLayout ll;
    @BindView(R.id.tv_certify)
    TextView tvCertify;
    @BindView(R.id.rl_certify)
    RelativeLayout rlCertify;
    @BindView(R.id.tv_set_psd)
    RelativeLayout tvSetPsd;
    @BindView(R.id.btn_submit)
    RelativeLayout btnSubmit;
    @BindView(R.id.tv_pwd_back)
    RelativeLayout tvPwdBack;

    @Override
    public int getLayoutContentId() {
        return R.layout.kingmall_activity_pay_pwd;
    }

    @Override
    public void initView() {
        setStatusBar();
        CommonUtil.initTitle(this, "支付密码管理", ll);
    }

    @Override
    public void initData() {

    }

    @Override
    protected void onResume() {
        super.onResume();
        OkGoUtils.normalRequest(MyUrl.getUserCertify, null, new onNormalRequestListener() {
            @Override
            public void onSuccess(String body, int code) {
                if (code == 0) {
                    UserCertifyBean bean = GsonUtils.getGson().fromJson(body, UserCertifyBean.class);
                    if (bean != null && bean.getCertify() != null) {
                        String status = "";
                        switch (bean.getCertify().getStatus()) {
                            case "0":
                                status = "未认证";
                                break;
                            case "1":
                                status = "已认证";
                                break;
                            case "2":
                                status = "认证中";
                                break;
                            case "3":
                                status = "被驳回";
                                break;
                        }
                        tvCertify.setText(status);
                    }
                }
            }

            @Override
            public void onError(Response<String> response) {

            }
        });
    }

    @OnClick({R.id.btn_submit, R.id.tv_set_psd, R.id.tv_pwd_back, R.id.rl_certify})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_submit:
                CommonUtil.startIntent(this,ModifyPayPwdActivty.class);
//                IntentUtils.getInstance()
//                        .with(this, WalletPayPassActivity.class)
//                        .putString(ConstansUtils.PARA, WalletPayPassActivity.ReSetPsd).start();
                break;
            case R.id.tv_set_psd:
//                IntentUtils.getInstance()
//                        .with(this, WalletPayPassActivity.class)
//                        .putString(ConstansUtils.PARA, WalletPayPassActivity.SetPsd).start();
                CommonUtil.startIntent(this,ModifyPayPwdSetActivty.class);
                break;
            case R.id.tv_pwd_back:
                CommonUtil.startIntent(this, ModifyPayPwdBackActivty.class);
                break;
            case R.id.rl_certify:
                //实名认证
                openActivity(RealNameAuthenteActivity.class);
                break;
        }
    }
}
